package cn.itcast.xml.jsoup;


import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.File;
import java.io.IOException;

/**
 * Jsoup快速入门
 */
public class JsoupDemo1 {
    public static void main(String[] args) throws IOException {
        //获取dom对象,根据xml文档获取
        //获取xml的path
        String path = JsoupDemo1.class.getClassLoader().getResource("student.xml").getPath();
        //解析xml文档,加载文档进内存
        Document document = Jsoup.parse(new File(path), "utf-8");
        //获取元素对象
        Element itcast = document.getElementById("itcast");
        Elements xing = itcast.getElementsByTag("xing");
        Element element = xing.get(0);
        String text = element.text();
        System.out.println(text);
    }

}
